package com.controller;

import com.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.lang.model.element.NestingKind;
import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {
    @RequestMapping("/getUserId")
    public void getUserId(HttpServletRequest request) {
        //HttpServletRequest是Servlet的 请求对象
        String userid = request.getParameter("userid");
        System.out.println("userid = " + userid);
    }
    @RequestMapping("/getUserMapping")
    public void getUserAndId(String username,Integer id){
        System.out.println("username = " + username);
        System.out.println("id = " + id);
    }
    @RequestMapping("/getUserName")
    public void getUserName (
            @RequestParam(value = "name",required = false,defaultValue = "itheima")String username
    ){
        System.out.println("username = " + username);
    }


    //pojo绑定
    @RequestMapping("/registerUser")
    public void registerUser(User user){
        String name = user.getName();
        String password = user.getPassword();
        System.out.println("name = " + name);
        System.out.println("password = " + password);

    }
}